package top.humbleyuan.datastructure.linkedlist;

/**
 * @Author HumbleYuan
 * @Date 2019/10/9 10:06
 * @Des 双向链表带孩子节点
 */
public class BothWayNode {
    public int val;
    public BothWayNode prev;
    public BothWayNode next;
    public BothWayNode child;

    public BothWayNode() {}

    public BothWayNode(int _val,BothWayNode _prev,BothWayNode _next,BothWayNode _child) {
        val = _val;
        prev = _prev;
        next = _next;
        child = _child;
    }

    public void formListNode(int values[]) {
        BothWayNode preTemp = this;
        for (int i = 0;i < values.length;i++) {
            BothWayNode nowTemp = new BothWayNode();
            preTemp.next = nowTemp;

            nowTemp.val = values[i];
            nowTemp.prev = preTemp;

            preTemp = nowTemp;
        }
        preTemp.next = null;
    }

}
